package com.quanquan.store.service;

import com.quanquan.store.entity.StoreFloor;
import com.quanquan.store.repository.FloorRepository;
import com.quanquan.store.repository.StoreFloorRepository;
import com.quanquan.store.repository.StoreRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import utils.DateUtils;
import utils.UUIDGenerator;

import java.util.Date;

/**
 * @ClassName:StoreFloorService
 * @Description:TODO
 * @Author:xiongjunbao
 * @Date:2019/3/13 9:56
 * @Version 1.0
 */
@Service
public class StoreFloorService {

    @Autowired
    private StoreFloorRepository storeFloorRepository;
    @Autowired
    private StoreRepository storeRepository;
    @Autowired
    private FloorRepository floorRepository;

    /**
     * 绑定商户与楼层的关系
     *
     * @param floorId
     * @param storeId
     * @return
     */
    public StoreFloor saveStoreFloor(String floorId, String storeId){
        Date date = new Date();
        StoreFloor storeFloor = new StoreFloor();
        storeFloor.setId(UUIDGenerator.getUUID());
        storeFloor.setFloorId(floorId);
        storeFloor.setStoreId(storeId);
        storeFloor.setStatusRemove(0);
        storeFloor.setStatusShow(0);
        storeFloor.setCreateTime(DateUtils.dateToString(date, DateUtils.TIMESTAMP));
        storeFloor.setUpdateTime(DateUtils.dateToString(date, DateUtils.TIMESTAMP));
        storeFloorRepository.saveAndFlush(storeFloor);
        return storeFloor;
    }



}
